package com.lp.article.mapper;

import com.lp.model.entity.article.ArticleStat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ArticleStatMapper {

    //根据 id 获取统计文件
    ArticleStat selectStatByArticleId(@Param("articleId") Long articleId);

    //新增统计文件
    void add(@Param("articleId") Long articleId,
             @Param("userId") Long userId);

    //文章访问量 + 1
    void visitsIncr(@Param("articleId") Long articleId,
                    @Param("visits") Long visits);

    //根据用户 id 获取统计信息
    List<ArticleStat> selectStatByUserId(@Param("userId") Long userId);

    //点赞量 + 1 或 - 1
    void likeIncrOrDecr(@Param("articleId") Long articleId,
                  @Param("count") Integer count);

    //收藏量 + 1 或 - 1
    void collectIncrOrDecr(@Param("articleId") Long articleId,
                  @Param("count") Integer count);

    //评论量 + 1 或 - 1
    void commentIncrOrDecr(@Param("articleId") Long articleId,
                           @Param("count") Integer count);

}
